from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains
import unittest
import os
from config.config import *
from public.utils.read_ini import Read_ini
from public.pages.basepage import BsaePage
from data.input_elem import Bbselem_Iput
from time import strftime
from public.utils.HTMLTestRunner3_New import HTMLTestRunner

file=os.path.join(data_path,"data.ini")
r=Read_ini(file)
url=r.read_ini_data("testbbs_data","url")
username=r.read_ini_data("testbbs_data","ls_username")
password=r.read_ini_data("testbbs_data","ls_password")
class Bbs_login(BsaePage):
    @classmethod
    def setUpClass(cls) -> None:
        driver=webdriver.Chrome()
        BsaePage.set_driver(driver)
        BsaePage.max()
    @classmethod
    def tearDownClass(cls) -> None:
        sleep(2)
    def test_bbslogin(self):
        a=BsaePage.get_driver()
        a.get(url)
        elem1=BsaePage.search_elem(Bbselem_Iput.bbs_account_input)
        BsaePage.sendkeys(elem1,username)
        elem2=BsaePage.search_elem(Bbselem_Iput.bbs_passwd_input)
        BsaePage.sendkeys(elem2,password)
        elem3=BsaePage.search_elem(Bbselem_Iput.bbs_loginbtn_input)
        BsaePage.click(elem3)
        try:
            elem4=BsaePage.search_elem(Bbselem_Iput.bbs_quit)
            value=BsaePage.text(elem4)
            self.assertEqual(value,"退出")
        except Exception as e:
            print(e)

if __name__ == '__main__':
    unittest.main()


























































